﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace 第二课堂评审系统.Models
{
    public class UserConfig : IEntityTypeConfiguration<User>
    {
        public void Configure(EntityTypeBuilder<User> builder)
        {
            builder.ToTable("T_User");
            builder.Property(u=>u.Name).HasMaxLength(20);
            builder.Property(u=>u.college).HasMaxLength(20);
            builder.Property(u=>u.address).HasMaxLength(100);
            builder.Property(u => u.passWord).HasMaxLength(50);
            builder.Property(u => u.avatar).HasMaxLength(100);
            builder.Property(u => u.telPhone).HasMaxLength(15);
            builder.Property(u => u.track).HasMaxLength(15);
            builder.Property(u => u.contactAddress).HasMaxLength(100);
            builder.HasMany(u => u.Roles).WithOne(r=>r.Users);//用户和角色多对多映射
        }
    }
}
